<?php 

namespace app\admin\model;

use think\Db;
use think\Model;
use app\admin\model\AdminUser;
class Department extends Model
{
    protected $table = "yzn_gd_department";

    //获取部门用户
    public static function getDepartmentUser($department_id)
    {
        $user = '';
        $list = Db::name('gd_department_user')->where(['department_id'=>$department_id])->select();
        foreach($list as $k=>$row){
            $user .= AdminUser::getAdmin($row['user_id'],'nickname').',';
        }
        return rtrim($user,',');
    }
    //获取部门用户id
    public static function getDepartmentUserId($department_id)
    {
        $userId = [];
        $list = Db::name('gd_department_user')->where(['department_id'=>$department_id])->select();
        foreach($list as $k=>$row){
            $userId[] = $row['user_id'];
        }
        return $userId;
    }

    public static function getNames($department_id)
    {
        return self::where('id',$department_id)->value('title');
    }
}